package com.ctg.itrdc.sysmgr.permission.core;

import java.io.Serializable;
import java.util.Objects;

public class CtgUser implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 系统用户登录账号
	 */
	private String sysUserCode;

	/**
	 * 系统用户标识，用户登录后取system_user.sys_user_id
	 */
	private Long sysUserId;

	/**
	 * 目前不用：这个应该以CACHE中为准，这里应该取不到
	 */
	private Long sysPostId;

	/**
	 * 目前不用：这个应该以CACHE中为准，这里应该取不到
	 */
	private String sysPostCode;

	/**
	 * 这个存放系统用户的角色ID，取system_user_role.sys_role_id
	 */
	private Long[] sysRoleId;

	/**
	 * 这个存放系统用户的角色名称，根据上面获取的每一个角色ID，从表system_roles取有效的system_roles.sys_role_code
	 */
	private String[] sysRoles;

	/**
	 * 系统用户所在的工号标识，根据当前的系统用户标识sysUserId从表system_user取：system_user.staff_id
	 */
	private Long staffId;

	/**
	 * 系统用户所在的工号名称，根据staffId从表staff中取：staff.staff_name
	 */
	private String staffName;
	
	/**
	 * 员工所在的组织标识，根据当前的系统工号标识staffId从表staff取：staff.org_id
	 */
	private Long rzOrgId;

	/**
	 * 员工所在组织的编码，根据当前的组织标识rzOrgId从表organization取：organization.org_code
	 */
	private String rzOrgCode;

	private boolean hasPost = true;
	
	public CtgUser() {
		super();
	}

	public CtgUser(String sysUserCode, Long sysUserId, Long staffId) {
		super();
		this.sysUserCode = sysUserCode;
		this.sysUserId = sysUserId;
		this.staffId = staffId;
	}

	public String getSysUserCode() {
		return sysUserCode;
	}

	public void setSysUserCode(String sysUserCode) {
		this.sysUserCode = sysUserCode;
	}

	public Long getSysUserId() {
		return sysUserId;
	}

	public void setSysUserId(Long sysUserId) {
		this.sysUserId = sysUserId;
	}

	public Long getSysPostId() {
		return sysPostId;
	}

	public void setSysPostId(Long sysPostId) {
		this.sysPostId = sysPostId;
	}

	public String getSysPostCode() {
		return sysPostCode;
	}

	public void setSysPostCode(String sysPostCode) {
		this.sysPostCode = sysPostCode;
	}

	public Long getStaffId() {
		return staffId;
	}

	public void setStaffId(Long staffId) {
		this.staffId = staffId;
	}

	public String getStaffName() {
		return staffName;
	}

	public void setStaffName(String staffName) {
		this.staffName = staffName;
	}

	public Long getRzOrgId() {
		return rzOrgId;
	}

	public void setRzOrgId(Long rzOrgId) {
		this.rzOrgId = rzOrgId;
	}

	public Long[] getSysRoleId() {
		return sysRoleId;
	}

	public void setSysRoleId(Long[] sysRoleId) {
		this.sysRoleId = sysRoleId;
	}

	public String[] getSysRoles() {
		return sysRoles;
	}

	public void setSysRoles(String[] sysRoles) {
		this.sysRoles = sysRoles;
	}

	public String getRzOrgCode() {
		return rzOrgCode;
	}

	public void setRzOrgCode(String rzOrgCode) {
		this.rzOrgCode = rzOrgCode;
	}

	public boolean getHasPost() {
		return hasPost;
	}
	
	public void setHasPost(boolean hasPost) {
		this.hasPost = hasPost;
	}
	
	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof CtgUser)) {
			return false;
		}
		CtgUser rhs = (CtgUser) object;
		return Objects.equals(this.sysUserCode, rhs.sysUserCode) && Objects.equals(this.sysPostId, rhs.sysPostCode)
				&& Objects.equals(this.sysUserId, rhs.sysUserId);
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return Objects.hash(this.sysUserCode, this.sysPostId, this.sysUserId);
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new StringBuilder("{\"sysUserCode\":\"").append(this.sysUserCode).append("\",\"sysUserId\":")
				.append(this.sysUserId).append(",\"sysPostId\":").append(this.sysPostId).append("}").toString();
	}

	public String toJSONString() {
		StringBuilder sb = new StringBuilder("{\"sysUserId\":").append(this.sysUserId).append(",\"sysUserCode\":")
				.append("\"").append(this.sysUserCode).append("\",\"sysPostId\":").append(this.sysPostId)
				.append(",\"sysPostCode\":").append("\"").append(this.sysPostCode).append("\",\"staffId\":")
				.append(this.staffId).append(",\"rzOrgId\":").append(this.rzOrgId).append(",\"rzOrgCode\":\"")
				.append(this.rzOrgCode).append("\"");
		if (this.sysRoles != null && this.sysRoles.length > 0) {
			sb.append(",\"sysRoles\":[");
			for (int i = 0; i < sysRoles.length; i++) {
				if (i != 0) {
					sb.append(",");
				}
				sb.append("\"").append(sysRoles[i]).append("\"");
			}
			sb.append("]");
		}
		return sb.append("}").toString();
	}

}